package com.sql.pool;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

import javax.xml.crypto.Data;

import com.sql.handler.Deploy;
import com.sql.handler.DriverClassName;

import com.sql.handler.XDCPool;
import com.sql.handler.util.ObjEqual;

public class Text {
	public volatile static int zz = 1;
	public static String stringss = "000000";
	public static void main(String...strings) throws IOException, ClassNotFoundException, IllegalAccessException, SQLException, InterruptedException{
		Deploy d = new Deploy()
				.setUrl("jdbc:mysql://127.0.0.1/fhm?characterEncoding=utf8&useSSL=true&useUnicode=true&characterEncoding=UTF8")
				.setUser("root")
				.setPassword("root")
				.setDriverClassName(DriverClassName.MySQL)
				.setCacheSize(10)
				.setNewMaxSize(500)
				.setCloseLog(true);
			XDCPool.init(d);
			
			int i;
			for(i = 0;i<100;i++){
				new Thread(new Runnable() {
					
					@Override
					public void run() {
						// TODO Auto-generated method stub
				
							for(int i=0;i<1;i++){

							Random r = new Random();
								XDCPool.getConnection();
//							XDCPool.insert("INSERT INTO userinfo (user,password) VALUES (?,?)", new String[]{r.nextInt()+"",stringss+""});
					
							System.out.println(zz++);

//							c.close();
							}
					
						
						
					}
				}).start();
				
			}
//			XDCPool.closeConnectionPool();
			
			
//			for(int i = 0;i<300;i++){
//				new Thread(new Runnable() {
//					
//					@Override
//					public void run() {
//						// TODO Auto-generated method stub
//						for(int j = 0;j<100;j++){
//							try {
//								java.sql.Connection d = SQLUtil.getConnection();
//								if(d == null){
//									System.out.println("~~~~~倒霉，拿到了空的连接！~~~~~~");
//								}
//								
//								Thread.sleep(30000);
////								if(j%2 == 0){
////									SQLUtil.release(d);
////								}else{
//									d.close();
////								}
//								SQLUtil.release(d);
//							
////								System.out.println("isValid:"+);
//
////								SQLUtil.release();
//							
//							} catch (SQLException e) {
//								// TODO Auto-generated catch block
//								e.printStackTrace();
//							} catch (ClassNotFoundException e) {
//								// TODO Auto-generated catch block
//								e.printStackTrace();
//							} catch (InterruptedException e) {
//								// TODO Auto-generated catch block
//								e.printStackTrace();
//							} catch (FileNotFoundException e) {
//								// TODO Auto-generated catch block
//								e.printStackTrace();
//							} catch (IllegalAccessException e) {
//								// TODO Auto-generated catch block
//								e.printStackTrace();
//							} catch (IOException e) {
//								// TODO Auto-generated catch block
//								e.printStackTrace();
//							} 
//						}
//					}
//				}).start();
//			}

		
		
	}

}
